home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / view3d < prev    next >
Encoding:
Text File  |  2000-05-21  |  1.1 KB  |  38 lines

  1. #!/usr/bin/perl
  2.  
  3. use Gimp::Feature qw(pdl);
  4. use PDL;
  5. BEGIN { eval "use PDL::Graphics::TriD"; $@ and Gimp::Feature::missing('PDL TriD (OpenGL) support') }
  6. use Gimp;
  7. use Gimp::Fu;
  8.  
  9. register
  10.     'view3d',
  11.     'View grayscale drawable in 3D',
  12.     'This script uses PDL::Graphics:TriD to view a grayscale drawable in 3D. You can choose a Cartesian (default) or Polar projection, toggle the drawing of lines, and toggle normal smoothing.',
  13.     'Tom Rathborne', 'GPLv2', '1999-03-11',
  14.     N_"<Image>/View/3D Surface...",
  15.     'RGB*,GRAY*', [
  16.         [ PF_BOOL, 'polar', 'Radial view', 0],
  17.         [ PF_BOOL, 'lines', 'Draw grid lines', 0],
  18.         [ PF_BOOL, 'smooth', 'Smooth surface normals', 1]
  19.     ], [],
  20. sub {
  21.     my ($img, $dwb, $polar, $lines, $smooth) = @_;
  22.  
  23.     my $w = $dwb->width;
  24.     my $h = $dwb->height;
  25.  
  26.     my $regn = $dwb->pixel_rgn (0, 0, $w, $h, 0, 0);
  27.     my $surf = $regn->get_rect (0, 0, $w, $h);
  28.     $surf=$surf->slice("(0)");
  29.  
  30.     imag3d [ $polar ? 'POLAR2D' : 'SURF2D', $surf ],
  31.            { 'Lines' => $lines, 'Smooth' => $smooth };
  32.  
  33.     ();
  34. };
  35.  
  36. exit main;
  37.  
  38.